
package com.joysuch.wwyt.risk.enums;

public enum ControlLevels {

    GONG_SI(188, "公司"),
    BU_MEN(186, "部门"),
    GANG_WEI(189, "岗位"),
    CHANG(190, "厂"),
    CHE_JIAN(191, "车间"),
    BAN_ZU(192, "班组");

    private int code;
    private String name;

    private ControlLevels(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static ControlLevels valueOf(int code) {
        ControlLevels[] values = ControlLevels.values();
        for (ControlLevels r : values) {
            if (r.code == code) {
                return r;
            }
        }
        return null;
    }

    public static String findControlLevelName(Integer code) {
        if (code == null) {
            return null;
        }
        ControlLevels of = valueOf(code);
        return of == null ? null : of.name;
    }

    public static ControlLevels findControlLevelByName(String name) {
        if (name == null) {
            return null;
        }
        ControlLevels[] values = ControlLevels.values();
        for (ControlLevels r : values) {
            if (r.name.equals(name)) {
                return r;
            }
        }
        return null;
    }

}
